//
// Created by user on 20-5-5.
//

#ifndef _ATOMIC_H_
#define _ATOMIC_H_

#define atomicRead(atomic)    ((atomic)->value)
#define atomicSet(atomic, val)    (((atomic)->value) = (val))

/**
 * 原子变量结构体
 */
typedef struct {
    __volatile__ long value;
} Atomic_T;

void atomicAdd(Atomic_T *atomic, long value);

void atomicSub(Atomic_T *atomic, long value);

void atomicInc(Atomic_T *atomic);

void atomicDec(Atomic_T *atomic);

void atomicSetMask(Atomic_T *atomic, long mask);

void atomicClearMask(Atomic_T *atomic, long mask);

#endif //_ATOMIC_H_
